package com.gitee.ywj1352.client;

import com.gitee.ywj1352.common.message.RequestMessage;
import com.gitee.ywj1352.common.message.ResponseMessage;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageDecoder;

import java.util.List;

/**
 * Decoder 对象
 */
public class ObjectDecoder extends MessageToMessageDecoder<ByteBuf> {

    @Override
    protected void decode(ChannelHandlerContext ctx, ByteBuf byteBuf, List<Object> out) throws Exception {
        ResponseMessage requestMessage = new ResponseMessage();
        requestMessage.decode(byteBuf);
        out.add(requestMessage);
    }
}